//: C03:DynamicDebugFlags.cpp
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 1999
// Copyright notice in Copyright.txt
#include <iostream>
#include <string>
using namespace std;
// Debug flags aren't necessarily global:
bool debug = false;

int main(int argc, char* argv[])
{
    for (int i = 0; i < argc; i++)
        if (string(argv[i]) == "--debug=on")
            debug = true;
    bool go = true;
    while (go) {
        if (debug) {
            // Debugging code here
            cout << "Debugger is now on!" << endl;
        } else {
            cout << "Debugger is now off." << endl;
        }
        cout << "Turn debugger [on/off/quit]: ";
        string reply;
        cin >> reply;
        if (reply == "on") debug = true; // Turn it on
        if (reply == "off") debug = false; // Off
        if (reply == "quit") break; // Out of 'while'
    }
} ///:~
